package com.tanhua.admin.controller;

import com.tanhua.admin.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/dashboard")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    /**
     * 新增、活跃用户、次日留存率---
     * GET /dashboard/users
     * Query：   sd	开始时间
     *
     * ed	结束时间
     *
     * type	101 新增 102 活跃用户 103 次日留存率
     */
    @GetMapping("/summary")
    public ResponseEntity summary(){
        //调用service进行查询
        Map map = dashboardService.summary();
        return ResponseEntity.ok(map);
    }
    /**
     * 新增、活跃用户、次日留存率
     * GET /dashboard/summary
     */
    @GetMapping("/users")
    public ResponseEntity users(Long sd,Long ed,String type){
        //调用service进行查询
        Map vo = dashboardService.users(sd,ed,type);
        //返回
        return ResponseEntity.ok(vo);
    }

}
